/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bayu.services.dao;

import com.bayu.services.entity.Pfrekap;
import java.util.List;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
/**
 *
 * @author Bayu
 */
@Repository("pfrekapDao")
@Transactional
public class PfrekapDao {
      private HibernateTemplate hibernateTemplate;

    @Autowired
    public void setSessionFactory(SessionFactory sessionFactory) {
	hibernateTemplate = new HibernateTemplate(sessionFactory);
    }

    @Transactional(readOnly = false)
    public void save(Pfrekap pf) {
       hibernateTemplate.saveOrUpdate(pf);
    }
    @Transactional(readOnly = false)
    public void delete(Pfrekap pf) {
        hibernateTemplate.delete(pf);
    }
    @Transactional(readOnly = false)
    public void update(Pfrekap pf) {
         hibernateTemplate.update(pf);
    }

    public List<Pfrekap> getAll(String query) {
        return hibernateTemplate.find(query);
    }

     public List<Pfrekap> getById(Long id) {
        return hibernateTemplate.find("from Pf where id="+id);
    }

      public List custom(String query){
       return hibernateTemplate.find(query);

    }

}
